package atm;


import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.*;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Albert
 */
public class Utils {
    public static String GetHiddenString(String s)
    {
        if (s.length()==0)
            return "";
        String temp = "";
        for (int i = 0; i< s.length(); i++)
            temp += '*';
        return temp;
    }

    public static ResultSet GetQuerySet(String query)
    {
        try
        {
            Class.forName(Constants.DBClass);
            Connection con = DriverManager.getConnection (Constants.DBUrl);
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(query);
            return rs;
        }
        catch (Exception e)
        {
            return null;
        }

    }

    public static void UpdateQuery(String query)
    {
        try
        {
            Class.forName(Constants.DBClass);
            Connection con = DriverManager.getConnection (Constants.DBUrl);
            Statement stmt = con.createStatement();
            stmt.executeUpdate(query);
        }
        catch (Exception ex)
        {
           Logger.getLogger(PINPage.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public static String AccountCodeToText(String s)
    {
       String result = "";
                if (s.equals(Constants.AccountChecking))
                {
                   result="Chequing";
                }
                if (s.equals("2"))
                {
                    result = "Savings";
                }
                if (s.equals("7"))
                {
                    result = "Credit Card";
                }
       return result;

    }
}
